package edu.chl.dat076.datesite.controllers;

import edu.chl.dat076.datesite.entities.Conversation;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.SelectEvent;

/**
 *
 * @author Christoffer
 */
@ManagedBean
@ViewScoped
public class ConversationBackingBean implements Serializable {

	private Conversation selectedConversation;

	public Conversation getSelectedConversation() {
		return selectedConversation;
	}

	public void setSelectedConversation(Conversation selectedConversation) {
		this.selectedConversation = selectedConversation;
	}
	
	public String navigate(SelectEvent event) {
		// conversation-sidan beter sig lite olika beroende på varifrån man kommer
		FacesContext.getCurrentInstance().getExternalContext().getFlash().put("mFromSite", "conversations");
        FacesContext.getCurrentInstance().getExternalContext().getFlash().put("conversation", selectedConversation);
        return "conversation.jsf?faces-redirect=true";
    }	
}